package com.s3.khospitalds.controller;

import com.s3.khospitalds.common.R;
import com.s3.khospitalds.entity.Complaintpatient;
import com.s3.khospitalds.service.ComplaintpatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: 想要告诉你
 * @CreateTime: 2025/3/11 14:54
 * @Description: 医生
 * @Version: 1.0
 */
@RestController
@CrossOrigin(origins = "*")
public class ComplaintpatientController {
    @Autowired
    private ComplaintpatientService complaintpatientService;
    //查询医生所有投诉
    @GetMapping("/getComplaintpatient")
    public R getComplaintpatient(){
        return new R().addData("Complaintpatient",complaintpatientService.selectAll());
    }

    //新增医生投诉信息
    @PostMapping("/insertComplaintpatient")
    public R insertComplaintpatient(@RequestBody Complaintpatient complaintpatient){
        System.out.println("complaintpatient = " + complaintpatient);
        return new R().addData("Complaintpatient",complaintpatientService.insert(complaintpatient));
    }
    //修改医生投诉信息
    @PostMapping("/updateComplaintpatient")
    public R updateComplaintpatient(@RequestBody Complaintpatient complaintpatient){
        return new R().addData("Complaintpatient",complaintpatientService.update(complaintpatient.getReply(), (int) complaintpatient.getId()));
    }
    //删除医生投诉信息
    @PostMapping("/deleteComplaintpatient")
    public R deleteComplaintpatient(@RequestBody Integer id){
        return new R().addData("Complaintpatient",complaintpatientService.delete(id));
    }
}
